﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using UnityEngine;
using System.Xml;

public class FileSurport 
{
    //解析XML,要求XML格式:mysql导出二维表
    public static Dictionary<int,Dictionary<string,string>> parseXML(string fileName)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load("configXML/" + fileName);

        XmlElement root = null;
        root = doc.DocumentElement;

        XmlNodeList listNodes = null;
        listNodes = root.SelectNodes("/RECORDS/RECORD");
        Dictionary<int,Dictionary<string,string>> result = new Dictionary<int,Dictionary<string,string>>();
        int index = 1;
        foreach (XmlNode node in listNodes)
	    {
		    XmlNodeList childs = node.ChildNodes;
            result[index] = new Dictionary<string, string>();
            foreach (XmlNode child in childs)
	        {
		        result[index][child.Name] = child.InnerText;
	        }
            index++;
	    }
        return result;
    }
}
